package com.example.skyline.controller;

import com.example.skyline.common.Result;
import com.example.skyline.service.VerificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/verification")
public class VerificationController {

    // 验证逻辑 排除在外 不需要token验证
    @Autowired
    private VerificationService verificationService;

    @Autowired
    RedisTemplate redisTemplate;

    // 存在账号：如果用户输入的账号已经存在，直接发送验证码可以提供流畅的用户体验。
    // 不存在账号
    // 生成验证码 --- redis --- 后续可能需要验证
    @PostMapping("/verifyCode")
    public Result verifyCode(@RequestParam String username) {
        String verificationCode = verificationService.createVerificationCode(username);
        return Result.success(verificationCode);
    }


}
